<?php

/**
 * @author ducnhat
 * @email ddnhat@gmail.com
 * @copyright 2014
 */
 
class ProductController extends Zenddn_Controller_Action{
	
    public function init(){
		parent::init();
        parent::loadTemplate('magashop');
        $this->view->page = "home";
	}
	
	public function indexAction(){
	    
	}
    
    public function detailAction(){
        parent::addScripts(array('jquery-price-format.min.js'));
        
        $request = $this->_request;
        
        $id = $request->getParam('product_id', false);
        
    	if($id){
            $model = new Default_Model_Product();
            $product = $model->getData($id, array(), true);
            
            if($product){
                $images = $model->getImages($id);
                $relatedProducts = $model->getRelatedProducts($id);
                $likeProducts = $model->getLikeProducts($id);
                
                $this->view->images = $images;
                $this->view->product = $product;
                $this->view->relatedProducts = $relatedProducts;
                $this->view->likeProducts = $likeProducts;
            }else{
                $this->_helper->_redirector->gotoRoute(array(), 'error', true);
            }
    	}
    }
}